import {
    getQuotedLists, getQuotedDetailInfo, saveQuotedPriceTable, fetchTaxInfo, fetchWorkTypeInfo,
    fetchCountServiceAndTax, fetchOtherWorkTypeInfo
} from '../../fetch/modules/quoted'

const state = {
    quotedLists: {
    },
    quotedDetailInfo: {},
    saveQoutedPriceInfo: {},
    taxInfo: {},
    workTypes: {},
    countServiceTax: {},
    otherWorkType: {}
}

const actions = {
    GET_QUOTED_LISTS: ({ commit, state }, opts) => {
        return getQuotedLists(opts).then(quoted => commit('FETCH_QUOTED_LISTS', { quoted }))
    },
    FETCH_QUOTED_DETAIL: ({ commit, state }, opts) => {
        return getQuotedDetailInfo(opts).then(quoted => commit('GET_QUOTED_DETAIL_INFO', { quoted }))
    },
    FETCH_SAVE_QUOTED_PRICE: ({ commit, state }, opts) => {
        return saveQuotedPriceTable(opts).then(quoted => commit('SAVE_QOUTED_PRICE_INFO', { quoted }))
    },
    GET_TAX_INFO: ({ commit, state }, opts) => {
        return fetchTaxInfo(opts).then(tax => commit('FETCH_TAX_IFNO', { tax }))
    },
    FETCH_WORK_TYPE: ({ commit, state }, opts) => {
        return fetchWorkTypeInfo(opts).then(workType => commit('GET_WORK_TYPES', { workType }))
    },
    FETCH_COUNT_SERVICETAX: ({ commit, state }, opts) => {
        return fetchCountServiceAndTax(opts).then(st => commit('COUNT_SERVICE_TAX', { st }))
    },
    FETCH_OTHER_WORK_TYPE: ({ commit, state }, opts) => {
        return fetchOtherWorkTypeInfo(opts).then(ot => commit('GET_OTHER_WORK_TYPE', { ot }))
    },
}
const mutations = {
    FETCH_QUOTED_LISTS: (state, { quoted }) => {
        state.quotedLists = quoted.data;
    },
    GET_QUOTED_DETAIL_INFO: (state, { quoted }) => {
        state.quotedDetailInfo = quoted.data;
    },
    SAVE_QOUTED_PRICE_INFO: (state, { quoted }) => {
        state.saveQoutedPriceInfo = quoted.data;
    },
    FETCH_TAX_IFNO: (state, { tax }) => {
        state.taxInfo = tax.data;
    },
    GET_WORK_TYPES: (state, { workType }) => {
        state.workTypes = workType.data;
    },
    COUNT_SERVICE_TAX: (state, { st }) => {
        state.countServiceTax = st.data;
    },
    GET_OTHER_WORK_TYPE: (state, { ot }) => {
        state.otherWorkType = ot.data;
    },
}

const getters = {
    getQuotedLists(state) {
        return state.quotedLists
    },
    getQuotedDetailInfo(state) {
        return state.quotedDetailInfo
    },
    getSaveQuotedPriceInfo(state) {
        return state.saveQoutedPriceInfo
    },
    getTaxInfo(state) {
        return state.taxInfo
    },
    getWorkTypeInfo(state) {
        return state.workTypes
    },
    getCountServiceTax(state) {
        return state.countServiceTax
    },
    getOtherWorkType(state) {
        return state.otherWorkType
    },
}

export default {
    state,
    actions,
    mutations,
    getters
}